<template>
  <div class="my-tag">
    <input
      class="input"
      type="text"
      placeholder="输入标签"
      v-if="isShowEdit1"
      @blur="handlerBlur"
      ref="inp"
      v-model="tag"
    />
    <div class="text" @dblclick="dbClickHandler" v-else >
      <slot name="tagName"></slot>
    </div>
  </div>
</template>
<script>
export default {
  props:{
    isShowEdit: Boolean,
    tagName: String,
    row: Object
  },
  data(){
    return {
      isShowEdit1: false,
      tag: ''
    }
  },
  methods:{
    handlerBlur(el){
      this.isShowEdit1 = false;
      this.$emit("getTagName", {value:el.target.value, row:this.row})
    },
    dbClickHandler(){
      this.isShowEdit1 = true
      this.$nextTick(()=>{
        this.$refs.inp.focus()
      })
      console.log(this.row.tag)
      this.tag=this.row.tag
    }

  }
}

</script>
<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>